const baseURL="https://scp.metahike.com/api/mp";
//const baseURL="http://api.scp.com/index.php/mp";
export function get(url,params){
	return new Promise((resolve,reject)=>{
		uni.request({
			method:'get',
			url:baseURL+url,
			data:params,
		}).then((response)=>{
			let [error,res]=response;
			resolve(res.data);
		}).catch(error=>{
			let [err,res]=error;
			reject(err);
		})
	})
}

export function post(url,params){
	return new Promise((resolve,reject)=>{
		uni.request({
			method:'post',
			url:baseURL+url,
			data:params,
			header:{
				"Token":uni.getStorageSync("token"),
				"Content-Type":"application/x-www-form-urlencoded"
			},
		}).then((response)=>{
			if(response.statusCode==401){
				uni.removeStorageSync("userinfo");
				uni.removeStorageSync("token");
				uni.navigateTo({
					url:'/pages/login/index'
				})
			}
			resolve(response);
		}).catch(error=>{
			console.log("error",resposne);
			reject(error);
		})
	})
}
